package com.hsu.easyweb.exception;

import com.hsu.easyweb.common.Error;

/**
 * 自定义业务异常类，用于在系统中统一处理业务逻辑错误。
 * @ClassName: BusinessException
 * @author Hsu琛君珩
 * @date 2024-09-09
 * @apiNote
 * @version v1.0
 */
public class BusinessException extends RuntimeException {
    private static final long serialVersionUID = -2970393916478025106L;
    private final int code;

    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(Error errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
    }

    public BusinessException(Error errorCode, String message) {
        super(message);
        this.code = errorCode.getCode();
    }

    public int getCode() {
        return this.code;
    }
}
